function [posts_final,posts_init,Q,gamma_final,kappa_final]=get_posts(theta,ests_wide,b_Omega,w_Omega,iter)

if iter==1
    options=struct('Display','iter','MaxFunEvals',10000000,'MaxIter',50000,'GradObj','off','TolFun',1e-6);
else
    options=struct('Display','none','MaxFunEvals',10000000,'MaxIter',50000,'GradObj','off','TolFun',1e-6);
end

% unpack
b_mu=exp(theta(1))/(1+exp(theta(1)));
w_mu=exp(theta(7))/(1+exp(theta(7)));
inv_V=inv(blkdiag(b_Omega,w_Omega));
L=length(ests_wide)/4;
ests=[ests_wide(1:2*L),ests_wide(2*L+1:4*L)];

% initialize & solve
psi_init=initial_posts(ests,b_mu,w_mu);
[psi_final,Q]=fminunc(@(x)post_lhood(x,theta,ests,inv_V),psi_init,options);  
gamma_init=[psi_init(1:L),psi_init(2*L+1:3*L)];
kappa_init=[psi_init(L+1:2*L),psi_init(3*L+1:4*L)];
gamma_final=[psi_final(1:L),psi_final(2*L+1:3*L)];
kappa_final=[psi_final(L+1:2*L),psi_final(3*L+1:4*L)];

% translate
posts_init=translate_posts([gamma_init;kappa_init],b_mu,w_mu);
posts_init=posts_init(:);
posts_final=translate_posts([gamma_final;kappa_final],b_mu,w_mu);
posts_final=posts_final(:);
